{extend name="base" /} {block name="css"}{/block} {block name="body"}
<div class="admin-main layui-form">
    <div class="layui-field-box">
        <div class="layui-box-searchber" style="overflow: visible">
            <a class="layui-btn layui-btn-sm" href="{:url('admin/siteAdmin/add')}">新增酷站</a>
            <button class="layui-btn layui-btn-normal layui-btn-sm" data-url="{:url('siteAdmin/pullNew')}" lay-submit lay-filter="pullNew">从LS服务器拉取酷站</button>
            <button class="layui-btn layui-btn-danger layui-btn-sm" data-url="{:url('admin/siteAdmin/alldelete')}"
                    lay-submit lay-filter="alldelete">删除选中
            </button>
            <div class="layui-form-pane">
                <form class="layui-form" action="{:url('admin/SiteAdmin/index')}" method="get">
                    <div class="layui-inline" style="width:100px">
                        <select name="category_id" lay-filter="selecttid">
                            <option value="">分类</option>
                            {volist name="category_level_list" id="vo"}
                            <option {if condition="$category_id eq $vo['id']" }selected="selected" {
                            /if} value="{$vo.id}">{neq name="vo.level"
                            value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <select name="status" lay-filter="selectstatus">
                            <option value="">全部状态</option>
                            <option {if condition="$status eq '0'" }selected="selected" {
                            /if} value="0">待审</option>
                            <option {if condition="$status eq 1" }selected="selected" {
                            /if} value="1">正常</option>
                            <option {if condition="$status eq 2" }selected="selected" {
                            /if} value="2">不通过</option>
                        </select>
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <input type="text" placeholder="加入日期始" value="{$startdate}" name="startdate" class="layui-input"
                               id="startdate">
                    </div>
                    <div class="layui-inline" style="width:100px">
                        <input type="text" placeholder="加入日期止" value="{$enddate}" name="enddate" class="layui-input"
                               id="enddate">
                    </div>


                    <div class="layui-inline" style="width:100px">
                        <input type="text" name="keyword" value="{$keyword}" placeholder="关键词" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">每页条数</label>
                        <div class="layui-inline" style="width:50px"><input type="number" name="perpage"
                                                                            value="{$perpage}" title placeholder="每页条数"
                                                                            class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-sm">搜索</button>
                    </div>


                </form>
            </div>
        </div>

        <hr>

        <table class="layui-table admin-table">
            <thead>
            <tr>
                <th width="10px" align="center"><input type="checkbox" name="checkAll"
                                                       lay-filter="checkAll"></th>
                <th width="60px" style="text-align:center">ID</th>
                <th style="min-width: 100px">网站标题</th>
                <th width="70px" style="text-align:center">所属分类</th>
                <th width="70px" style="text-align:center">状态</th>
                <th width="70px" style="text-align:center">星级</th>
                <th width="100px" style="text-align:center">加入时间</th>
                <th width="80px" style="text-align:center">访问量</th>
                <th width="90px" style="text-align:center">站长QQ</th>
                <th width="120px" style="text-align:center">操作</th>
            </tr>
            </thead>
            <tbody id="content">
            {volist name="site_list" id="vo"}
            <tr>
                <td align="center"><input type="checkbox" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}">
                </td>
                <td align="center">{$vo.id}</td>
                <td style="padding-left: 20px;"><a target="_blank"
                                                   href="{:routerurl('index/index/detail',array('id'=>$vo.id))}">{$vo.title}</a>
                    <a class="layui-btn layui-btn-primary layui-btn-xs" target="_blank" href="{$vo.link}">访问</a>
                </td>
                <td align="center"><a
                        href="{:url('admin/SiteAdmin/index')}?category_id={$vo.category_id}">{$vo.name}</a></td>
                <td align="center">
                    {if $vo.status eq 0}<span style="padding:5px;background:yellow">待审</span>{elseif
                    $vo.status eq 1}正常 {else/}<span
                        style="padding:5px;color:#FFF;background:red">不通过</span>{/if}
                </td>
                <td align="center"><img src="__ADMIN__/images/hot/{$vo.stars}.gif" class="star"></td>
                <td align="center">{:friendlyDate(strtotime($vo['joined_at']))}</td>
                <td align="center">{$vo['total_view']}</td>

                <td style="padding-left: 20px;"><a style="点击可打开QQ" href="http://wpa.qq.com/msgrd?v=3&amp;uin={$vo.webmaster_qq}&amp;site=qq&amp;menu=yes" target="_blank">{$vo.webmaster_qq}</a>
                <td align="center">
                    <a class="layui-btn layui-btn-normal layui-btn-sm"
                       href="{:url('Admin/siteAdmin/edit',array('id'=>$vo['id']))}">编审</a>
                    <a class="elementdel layui-btn layui-btn-danger layui-btn-sm" href="javascript:;" data-id="{$vo.id}"
                       data-url="{:url('admin/siteAdmin/delete',array('id'=>$vo['id']))}" title="删除">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>


</div>
{/block} {block name="page"}
<div class="btable-paged">
    <div class="formbtngroup">
        {$site_list->render()}
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
{/block} {block name="script"}

<script>
    layui.use(['form', 'laydate'], function () {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function (data) {
            $form.submit();
        });

        form.on('submit(set7DayViews)', function (data) {
            var is_check = false;
            jq("input[lay-filter='checkOne']").each(function () {
                if (jq(this).prop('checked')) {
                    is_check = true;
                }
            });
            if (!is_check) {
                layer.msg('请选择数据', {icon: 2, anim: 6, time: 1000});
                return false;
            }
            var num = Math.ceil(Math.random() * 1000);
            var url = jq(this).data('url');
            layer.prompt({title: '系统会从1开始随机，请输入最大随机数', value: num}, function (text, index) {
                layer.alert('该功能下一版本见吧！', {icon: 6});
            });
        })

        form.on('submit(setHotSite)', function (data) {
            var is_check = false;
            jq("input[lay-filter='checkOne']").each(function () {
                if (jq(this).prop('checked')) {
                    is_check = true;
                }
            });
            if (!is_check) {
                layer.msg('请选择数据', {icon: 2, anim: 6, time: 1000});
                return false;
            }
            var url = jq(this).data('url');

            layer.prompt({title: '设置 0:普通 1:推荐 2:名站'}, function (text, index) {
                data.field.famous = text;
                var param = data.field;
                jq.post(url, param, function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1000
                        },function () {
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            anim: 6,
                            time: 1000
                        });
                    }
                });
            });
        })
        laydate.render({
            elem: '#startdate' //指定元素
            ,
            done: function (value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
            ,
            done: function (value, date) {
                $form.submit();
            }
        });
        var status = 0;
        form.on('switch(switchstatus)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/siteAdmin/toggle')}?id=" + data.value + '&status=' + status + '&name=status';


            jq.get(url, function (data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        form.on('switch(switchchoice)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/siteAdmin/toggle')}?id=" + data.value + '&status=' + status + '&name=choice';


            jq.get(url, function (data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchsettop)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/siteAdmin/toggle')}?id=" + data.value + '&status=' + status + '&name=settop';


            jq.get(url, function (data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        form.on('switch(switchcarousel)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('admin/siteAdmin/toggle')}?id=" + data.value + '&status=' + status + '&name=carousel';


            jq.get(url, function (data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });


    })
</script>
{/block}